// -*-mode:c++; coding:utf-8-*-

#ifndef _XBASE_LOG_MANAGER_HPP_
#define _XBASE_LOG_MANAGER_HPP_ "hepengfei"

#include <boost/shared_ptr.hpp>
#include <boost/thread.hpp>
#include <boost/bind.hpp>

#include <protocol.hpp>

#include "log_thread.hpp"
//#include "log_roll_back_thread.hpp"

namespace xbase
{
	// need: the_conf gfs 
	class log_manager
	{
	public:
		typedef boost::shared_ptr<log_manager> pointer;
	public:
		// interface
		bool start_service() {
			m_logger.reset(new log_thread());
			m_log_thread.reset(new boost::thread(boost::bind(&log_thread::operator(), boost::ref(m_logger))));
			return true;
		}

		log_thread &logger() {
			return *m_logger;
		}

		void stop() {
			m_logger->stop();
		}

		void join() {
			m_log_thread->join();
		}

	private:
		boost::shared_ptr<log_thread> m_logger;
		boost::shared_ptr<boost::thread> m_log_thread;
	};
} // namespace xbase

#endif	// _XBASE_LOG_MANAGER_HPP_
